package org.wgc.study.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.wgc.study.enums.AiAbilityEnum;
import org.wgc.study.service.AiAbilityInterface;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 *@title AiAbilityFactory
 *@description <TODO description class purpose>
 *@author wgc_j
 *@version 1.0.0
 *@create 2025-08-01 10:04
 **/
@Component
public class AiAbilityFactory {
    @Autowired
    private List<AiAbilityInterface> abilityInterfaces;

    private Map<AiAbilityEnum, AiAbilityInterface> abilityInterfaceMap;

    @PostConstruct
    public void init() {
        abilityInterfaceMap = new HashMap<>();
        for (AiAbilityInterface anInterface : abilityInterfaces) {
            abilityInterfaceMap.put(anInterface.name(), anInterface);
        }
    }
    public AiAbilityInterface getAbility(AiAbilityEnum name) {
        return abilityInterfaceMap.get(name);
    }
}
